#pragma once

#include <iostream>
#include <functional>

//下面这句代码等价于
// typedef std::function<void()> tasl_t;
// using task_t = std::function<void()>;

// void download()
// {
//     std::cout << "I am a download task." << std::endl;
    
// }

class Task
{
public:
    Task()
    {}
    
    Task(int x, int y)
        :_x(x)
        ,_y(y)
    {

    }

    void excute()
    {
        _result = _x + _y;
    }

    void operator()()
    {
        excute();
    }

    std::string debug()
    {
        std::string message = std::to_string(_x) + "+" + std::to_string(_y) + "= ?   ";
        return message;
    }
    
    std::string result()
    {
        std::string message = std::to_string(_x) + "+" + std::to_string(_y) + "= " + std::to_string(_result);
        return message;
    }
private:
    int _x;
    int _y;
    int _result;
};
